<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('审读样本列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row ">


            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h4 style="font-size: 22px;text-align: center;font-family: 'Arial Bold', 'Arial Normal', 'Arial';font-weight: 700;">每日样本统计</h4>
                        <div class="ibox-tools">
                            <a class="collapse-link" onclick="$.modal.openTab('样本数量统计按天','/statistics/IdSampleNumberDay')">
                                <i class="fa fa fa-bars"></i>
                                更多
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">

                        <div class="echarts" id="echarts-bar-chart"></div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">

            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h4 style="font-size: 22px;text-align: center;font-family: 'Arial Bold', 'Arial Normal', 'Arial';font-weight: 700;">月度样本统计</h4>
                        <div class="ibox-tools">
                            <a class="collapse-link" onclick="$.modal.openTab('样本数量统计按月','/statistics/IdSampleNumberMonth')">
                                <i class="fa fa fa-bars"></i>
                                更多
                            </a>
                        </div>

                    </div>
                    <div class="ibox-content">
                        <div class="echarts" id="echarts-month-chart"></div>
                    </div>
                </div>
            </div>

        </div>

        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h4 style="font-size: 22px;text-align: center;font-family: 'Arial Bold', 'Arial Normal', 'Arial';font-weight: 700;">年度样本统计</h4>
                        <div class="ibox-tools">
                            <a class="collapse-link" onclick="$.modal.openTab('样本数量统计按年','/statistics/IdSampleNumberYear')">
                                <i class="fa fa fa-bars"></i>
                                更多
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div class="echarts" id="echarts-year-chart"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: echarts-js" />

<script type="text/javascript">
    $(function () {

        var barChart = echarts.init(document.getElementById("echarts-bar-chart"));

        barChart.setOption({
            color:['#3aa1ff','#4ecb73','#00FFFF','#fbd437'],

            tooltip: {
                trigger: 'axis',
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            legend: {
                data: ['正式出版物', '非法出版物','其他', '待鉴定'],

                y:'bottom',
            },
            grid: {
                left: '3%',
                right: '4%',
                // bottom: '20%',
                top:'3%',
                bottom:'10%',

                containLabel: true
            },

            yAxis: {
            },
            xAxis: {
                data: []
            },

            series: [{
                name: '正式出版物',
                type: 'bar',
                data: []
            },{
                name: '非法出版物',
                type: 'bar',
                data: []
            },{
                name: '其他',
                type: 'bar',
                data: []
            },{
                name: '待鉴定',
                type: 'bar',
                data: []
            }

            ]
        });

        $.ajax({
            type: "post",
            url: ctx + "statistics/listIdSampleNumberDay",
            data: {
                "beginTime": null,
                "endTime":null,
            },
            success: function(data) {
                var dataObj = data.rows
                var timeArr=[]


                var legals=[]
                var illegals=[]
                var otherlegals=[]
                var waits=[]

                $.each(dataObj, function(index, item){
                    var param = [];



                    timeArr.push(item.times)
                    otherlegals.push(item.otherlegal)
                    legals.push(item.legal)
                    illegals.push(item.illegal)
                    waits.push(item.wait)

                });

                barChart.setOption({

                    xAxis: {
                        data: timeArr
                    },
                    series: [{
                        name: '正式出版物',
                        type: 'bar',
                        stack: '总量',
                        label: {
                            show: true,
                            position: 'inside'
                        },
                        data: legals
                    },
                        {
                            name: '非法出版物',
                            type: 'bar',
                            stack: '总量',
                            label: {
                                show: true,
                                position: 'inside'
                            },
                            data: illegals
                        },
                        {
                            name: '其他',
                            type: 'bar',
                            stack: '总量',
                            label: {
                                show: true,
                                position: 'inside'
                            },
                            data: otherlegals
                        },
                        {
                            name: '待鉴定',
                            type: 'bar',
                            stack: '总量',
                            label: {
                                show: true,
                                position: 'inside'
                            },
                            data: waits
                        },

                    ]
                });
                // window.onresize = barChart.resize;
            }
        });



        window.onresize = barChart.resize;




        var monthChart = echarts.init(document.getElementById("echarts-month-chart"));
        monthChart.setOption({
            color:['#3aa1ff','#4ecb73','#00FFFF','#fbd437'],

            tooltip: {
                trigger: 'axis',
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            legend: {
                data: ['正式出版物', '非法出版物', '其他', '待鉴定'],

                y:'bottom',
            },
            grid: {
                left: '3%',
                right: '4%',
                // bottom: '20%',
                top:'3%',
                bottom:'10%',

                containLabel: true
            },

            yAxis: {
            },
            xAxis: {
                data: []
            },

            series: [{
                name: '正式出版物',
                type: 'bar',
                data: []
            },{
                name: '非法出版物',
                type: 'bar',
                data: []
            },{
                name: '其他',
                type: 'bar',
                data: []
            },{
                name: '待鉴定',
                type: 'bar',
                data: []
            }

            ]
        });
        $(window).resize(monthChart.resize);


        $.ajax({
            type: "post",
            url: ctx + "statistics/listIdSampleNumberMonth",
            data: {
                "beginTime": null,
                "endTime":null,
            },
            success: function(data) {
                var dataObj = data.rows
                // console.log(dataObj)
                var timeArr=[]
                var legals=[]
                var otherlegals=[]
                var illegals=[]
                var waits=[]
                $.each(dataObj, function(index, item){
                    var param = [];

                    timeArr.push(item.times)
                    otherlegals.push(item.otherlegal)
                    legals.push(item.legal)
                    illegals.push(item.illegal)
                    waits.push(item.wait)

                });

                // for (var i=1;i<=12;i++){
                //     timeArr.push(numberChange(i)+"月")
                // }
// legals.push(dataObj.janlegal);illegals.push(dataObj.janillegal);waits.push(dataObj.janwait);otherlegals.push(dataObj.janotherlegal);
// legals.push(dataObj.feblegal);illegals.push(dataObj.febillegal);waits.push(dataObj.febwait);otherlegals.push(dataObj.febotherlegal);
// legals.push(dataObj.marlegal);illegals.push(dataObj.marillegal);waits.push(dataObj.marwait);otherlegals.push(dataObj.marotherlegal);
// legals.push(dataObj.aprlegal);illegals.push(dataObj.aprillegal);waits.push(dataObj.aprwait);otherlegals.push(dataObj.aprotherlegal);
// legals.push(dataObj.maylegal);illegals.push(dataObj.mayillegal);waits.push(dataObj.maywait);otherlegals.push(dataObj.mayotherlegal);
// legals.push(dataObj.junelegal);illegals.push(dataObj.juneillegal);waits.push(dataObj.junewait);otherlegals.push(dataObj.juneotherlegal);
// legals.push(dataObj.julylegal);illegals.push(dataObj.julyillegal);waits.push(dataObj.julywait);otherlegals.push(dataObj.julyotherlegal);
// legals.push(dataObj.auglegal);illegals.push(dataObj.augillegal);waits.push(dataObj.augwait);otherlegals.push(dataObj.augotherlegal);
// legals.push(dataObj.septlegal);illegals.push(dataObj.septillegal);waits.push(dataObj.septwait);otherlegals.push(dataObj.septotherlegal);
// legals.push(dataObj.octlegal);illegals.push(dataObj.octillegal);waits.push(dataObj.octwait);otherlegals.push(dataObj.octotherlegal);
// legals.push(dataObj.novlegal);illegals.push(dataObj.novillegal);waits.push(dataObj.novwait);otherlegals.push(dataObj.novotherlegal);
// legals.push(dataObj.decelegal);illegals.push(dataObj.deceillegal);waits.push(dataObj.decewait);otherlegals.push(dataObj.deceotherlegal);

                console.log(waits)
                monthChart.setOption({
                    xAxis: {
                        data: timeArr
                    },
                    series: [{
                        name: '正式出版物',
                        type: 'bar',
                        stack: '总量',
                        label: {
                            show: true,
                            position: 'inside'
                        },
                        data: legals
                    },
                        {
                            name: '非法出版物',
                            type: 'bar',
                            stack: '总量',
                            label: {
                                show: true,
                                position: 'inside'
                            },
                            data: illegals
                        },
                        {
                            name: '其他',
                            type: 'bar',
                            stack: '总量',
                            label: {
                                show: true,
                                position: 'inside'
                            },
                            data: otherlegals
                        },
                        {
                            name: '待鉴定',
                            type: 'bar',
                            stack: '总量',
                            label: {
                                show: true,
                                position: 'inside'
                            },
                            data: waits
                        },

                    ]
                });
                // window.onresize = barChart.resize;
            }
        });










        var yearChart = echarts.init(document.getElementById("echarts-year-chart"));
        yearChart.setOption({
            color:['#3aa1ff','#4ecb73','#00FFFF','#fbd437'],

            tooltip: {
                trigger: 'axis',
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            legend: {
                data: ['正式出版物', '非法出版物', '其他', '待鉴定'],

                y:'bottom',
            },
            grid: {
                left: '3%',
                right: '4%',
                // bottom: '20%',
                top:'3%',
                bottom:'10%',

                containLabel: true
            },

            yAxis: {
            },
            xAxis: {
                data: []
            },

            series: [{
                name: '正式出版物',
                type: 'bar',
                data: []
            },{
                name: '非法出版物',
                type: 'bar',
                data: []
            },{
                name: '其他',
                type: 'bar',
                data: []
            },{
                name: '待鉴定',
                type: 'bar',
                data: []
            }

            ]
        });

        $(window).resize(yearChart.resize);


        $.ajax({
            type: "post",
            url: ctx + "statistics/listIdSampleNumberYear",
            data: {
                "beginTime": null,
                "endTime":null,
            },
            success: function(data) {
                console.log(data)
                var dataObj = data.rows
                var timeArr=[]
                var legals=[]
                var illegals=[]
                var waits=[]
                $.each(dataObj, function(index, item){
                    timeArr.push(item.times)
                    legals.push(item.legal)
                    illegals.push(item.illegal)
                    waits.push(item.wait)

                });
                yearChart.setOption({
                    xAxis: {
                        data: timeArr
                    },
                    series: [{
                        name: '正式出版物',
                        type: 'bar',
                        stack: '总量',
                        label: {
                            show: true,
                            position: 'inside'
                        },
                        data: legals
                    },
                        {
                            name: '非法出版物',
                            type: 'bar',
                            stack: '总量',
                            label: {
                                show: true,
                                position: 'inside'
                            },
                            data: illegals
                        },
                        {
                            name: '其他',
                            type: 'bar',
                            stack: '总量',
                            label: {
                                show: true,
                                position: 'inside'
                            },
                            data: illegals
                        },
                        {
                            name: '待鉴定',
                            type: 'bar',
                            stack: '总量',
                            label: {
                                show: true,
                                position: 'inside'
                            },
                            data: waits
                        },

                    ]
                });
                // window.onresize = barChart.resize;
            }
        });
    });

    function numberChange(num){
        var result="";

         if(num==1){
            result="一"
        }else if(num==2){
            result="二"
        }else if(num==3){
            result="三"
        }else if(num==4){
            result="四"
        }else if(num==5){
            result="五"
        }else if(num==6){
            result="六"
        }else if(num==7){
            result="七"
        }else if(num==8){
            result="八"
        }else if(num==9){
            result="九"
        }else if(num==10){
            result="十"
        }else if(num==11){
            result="十一"
        }else if(num==12){
            result="十二"
        }
        return result;
}
</script>
</body>
</html>